package cate.game.play.part;

import cate.common.table.d.GDPosition;
import cate.common.table.item.hero.row.HeroBaseRow;
import cate.game.play.bg.HeroBg;
import cate.game.play.fighter.HeroFighter;
import cate.game.play.support.PlayBuildContext;
import cate.game.play.vo.HeroVO;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;

@NoteClass(value = "上阵的英雄",detail = "已经计算过属性 加载过技能 用于生成heroFighter")
public class BattleHero extends BattleFighter<BattleHero>{

	@NoteField("英雄简要数据")
	public HeroVO hero;

	@NoteField("位置")
	public byte pos;

	@NoteField("皮肤")
	public int skin;

	@NoteField(value = "英雄背景",detail = "")
	public HeroBg bg;

	@NoteField("英雄来源")
	public byte origin = GDPosition.Origin.BAG;

	public HeroFighter buildFighter(PlayBuildContext ctx) {
		HeroFighter fighter = new HeroFighter();
		fighter.init();
		fighter.uid = hero.uid;
		fighter.heroTid = hero.tid;
		fighter.level = Math.max(hero.level, hero.shareLevel);
		HeroBaseRow baseRow = hero.getTpl(ctx);
		fighter.star = baseRow.star;
		fighter.protoId = baseRow.protoId;
		fighter.camp = baseRow.camp;
		fighter.job = baseRow.job;
		//设置属性
		fighter.attr.addSelfAttr(attr);
		fighter.attr.addPvpAttr(pvpAttr);
		//设置技能
		fighter.skill.addSkills(skills);
		fighter.skill.addPvPSkills(pvpSkills);
		//设置位置
		fighter.setPos(pos);
		return fighter;
	}

	public BattleHero copy() {
		BattleHero cp = new BattleHero();
		cp.readFrom(this);
		cp.hero = this.hero == null ? null : this.hero.copy();
		cp.pos = this.pos;
		cp.skin = this.skin;
		cp.bg = this.bg == null ? null : this.bg.copy();
		cp.origin = this.origin;
		return cp;
	}
}
